/** 
* All Rights Reserved , Copyright (C) 2020 , 青岛鼎信通讯股份有限公司
* 
* PmChangeApplyService
* 变更申请单
* 
* 修改纪录
* 2020-05-27 版本：1.0 shenyouyi 创建。
* @version 版本：1.0
* @author 作者：shenyouyi
* 创建日期：2020-05-27
*/
package com.topscomm.pm.service.impl;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.topscomm.pm.service.IPmChangeApplyService;
import com.topscomm.pm.service.impl.auto.PmChangeApplyServiceAuto;
import com.topscomm.basic.BasicEntity;
import com.topscomm.basic.util.PrimaryKeyUtil;
import com.topscomm.pm.pojo.PmChangeApplyEntity;

@Service(value = "pmChangeApplyService")
@Scope(value = "singleton")
public class PmChangeApplyService extends PmChangeApplyServiceAuto implements IPmChangeApplyService {
	/**
	 * @author: shenyouyi
	 * @date: 2020-05-27
	 * @param entity
	 * @description:单号生成
	 * @modify:
	 */
	@Override
	protected void beforeInsert(BasicEntity entity){		
		super.beforeInsert(entity);
		if (entity.getId() <= 0) {// 赋值Id和单号
			long[] arrayId = PrimaryKeyUtil.GeneIDs(entity.getTableName(), 1);
			entity.setId(arrayId[0]);
			String docNo = String.valueOf(arrayId[0]);
			docNo = docNo.substring(0, 6) + docNo.substring(9);
			entity.setValue(PmChangeApplyEntity.FieldDocno, docNo);
		}
	}
}
